package Model.OtherUser;

import java.io.IOException;
import java.util.Date;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import DBAccess.DBAccess;
import Model.Flirt;

/**
 * Servlet implementation class RegistrationServlet
 */
@WebServlet("/manageother")
public class ProfileServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	 @Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 new DBAccess();
		 int userID = Integer.parseInt(request.getParameter("userID"));
		 int profileID = Integer.parseInt(request.getParameter("profileID"));
			String button = request.getParameter("button");
			if(button.equals("Block me")){
				Blocked.addBlocked(userID, profileID);
				response.sendRedirect("http://localhost:8080/UBCDatingServer/report.jsp?id="+profileID);
				return;
			} else if(button.equals("Unblock me") || button.equals("Unfriend me")){
				OtherUser.removeOtherUser(userID, profileID);
			} else if(button.equals("Friend me")){
				Friends.addFriend(userID, profileID, "other friends");
			} else if(button.equals("Flirt!")){
				Flirt.flirt(userID, profileID);
			} else if(button.equals("Yes")){
				Blocked.reportUser(userID, profileID);
				response.sendRedirect("http://localhost:8080/UBCDatingServer/profile.jsp");
				return;
			}
			String referer = request.getHeader("Referer");
			response.sendRedirect(referer);
			return;

		}

}
